package com.xls.aclservice.controller;


import com.xls.base.annotation.Log;
import com.xls.commonutils.Result;
import com.xls.aclservice.entity.SysMenu;
import com.xls.aclservice.service.SysMenuService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xls
 * @since 2021-03-23
 */
@RestController
@RequestMapping("/admin/acl/menu")
@Api(value="菜单接口")
@Slf4j
public class SysMenuController {

    @Autowired
    private SysMenuService sysMenuService;

    @Log(title = "菜单管理", businessType = "查询")
    @PreAuthorize("hasAnyAuthority('system:sysMenu:list')")
    @GetMapping("/getMenus")
    public Result<List<SysMenu>> getMenus() {
        return Result.success(sysMenuService.getMenus());
    }

    @Log(title = "菜单管理", businessType = "修改")
    @PreAuthorize("hasAnyAuthority('system:sysMenu:update')")
    @PostMapping("/updateStatus")
    public Result<SysMenu> remove(@RequestBody SysMenu sysMenu) {
        sysMenuService.removeMenu(sysMenu);
        return Result.success();
    }

}

